package com.lk.wz.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

import com.lk.wz.config.dbConfig;

public class DBUtil {
	public static Connection getConnection(){
		Connection conn=null;
		Properties props =new dbConfig().getDBProperties();
		try {
			Class.forName(props.getProperty("driver"));
			conn=DriverManager.getConnection(props.getProperty("url"),
					props.getProperty("user"),props.getProperty("password"));
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return conn;
	}
	
	public static void closeConnection(Connection conn){
		if(conn!=null){
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	public static void main(String[] args){
		getConnection();
	}

}
